/*
 * @Author: your name
 * @Date: 2021-09-15 10:43:13
 * @LastEditTime: 2021-09-16 13:33:37
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \media_system\db\models\user.js
 */
var moment = require('moment');
module.exports = (sequelize, DataTypes) => {
  const DietRecordDetail = sequelize.define('dietRecordDetail', {
    foodWeight: {
      type: DataTypes.DOUBLE,
      comment: '食物重量'
    },
    createdAt: {
      type: DataTypes.DATE,
      get() {
        const createdAt = this.getDataValue('createdAt')
        // createAt is an instance of date, you could operate it with moment library
        // to get ur format
       return moment(createdAt).format('YYYY-MM-DD HH:mm:ss');
      },
      set(createdAt) {
        return this.setDataValue('createdAt',createdAt)
      }
    },
    updatedAt: {
      type: DataTypes.DATE,
      get() {
        const updatedAt = this.getDataValue('updatedAt')
        // createAt is an instance of date, you could operate it with moment library
        // to get ur format
       return moment(updatedAt).format('YYYY-MM-DD HH:mm:ss');
      },
      set(updatedAt) {
        return this.setDataValue('updatedAt',updatedAt)
      }
    }
  },
    {
      tableName: 'dietRecordDetail',
      timestamps: true
    });

  return DietRecordDetail
}





